﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using bbtpClient.Entities;
using bbtpClient.Controllers;

namespace bbtpClient
{
    public partial class CreateOrderForReturnForm : Form
    {
        public CreateOrderForReturnForm(OrderHead[] orders)
        {
            InitializeComponent();
            label_UserName.Text = UserInfo.Name;
            orders_listBox.Items.AddRange(orders);
            orders_listBox.Invalidate();
        }

        private void createOrderForReturn_button_Click(object sender, EventArgs e)
        {          
            int selectedOrderIndex = orders_listBox.SelectedIndex;
            OrderHead order = (OrderHead)orders_listBox.Items[selectedOrderIndex];
            SalesmanController.CreateOrderForReturn(order.id, this);
        }

        public void RemoveSelectedOrder()
        {
            int selectedOrderIndex = orders_listBox.SelectedIndex;
            orders_listBox.Items.RemoveAt(selectedOrderIndex);
       }

        private void exit_button_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}